home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 584 / program / gfa / squaring.lst < prev   
Encoding:
File List  |  1992-03-19  |  1.8 KB  |  86 lines

  1. ' A best way to TEST your TT hardware speed!  Grin!
  2. '
  3. Clear
  4. Dim Lattice(159,79),L2(159,79)
  5. ' Double each number above arguments to BOOST your TT/ST memory for LONGER
  6. ' number calculations - the bigger number, the longer computation time....
  7. ' Use your calculator to see how limitation is your calculator! :-)
  8. '
  9. Input "Enter a number to be multiplied by itself (try 2): ",A$
  10. Do
  11.   B$=A$
  12.   Arrayfill Lattice(),0
  13.   Arrayfill L2(),0
  14.   '
  15.   L$=""
  16.   Sizeb=Len(B$)
  17.   Sizea=Len(A$)
  18.   Max=Sizea+Sizeb
  19.   For Row=1 To Sizeb
  20.     A=Val(Mid$(B$,Row,1))
  21.     For Col=1 To Sizea
  22.       B=Val(Mid$(A$,Col,1))
  23.       Answer=B*A
  24.       If Answer<10
  25.         Product$="0"+Str$(Answer)
  26.       Else
  27.         Product$=Str$(Answer)
  28.       Endif
  29.       L$=L$+Mid$(Product$,1,1)+Mid$(Product$,2,1)
  30.     Next Col
  31.   Next Row
  32.   '
  33.   Col=Sizea*2
  34.   Y=0
  35.   Repeat
  36.     X=0
  37.     Repeat
  38.       Inc X
  39.       V$=Mid$(L$,X+Col*Y,1)
  40.       Lattice(X,Y)=Val(V$)
  41.     Until X=Col
  42.     Inc Y
  43.   Until Y=Sizeb
  44.   '
  45.   For Y=0 To Sizeb-1
  46.     L2(Y,Y)=Lattice(1,Y)
  47.     For X=2 To Col-1 Step 2
  48.       L2(Y+X/2,Y)=Lattice(X,Y)+Lattice(X+1,Y)
  49.     Next X
  50.     L2(Sizea+Y,Y)=Lattice(Col,Y)
  51.   Next Y
  52.   '
  53.   For Y=0 To Sizeb-1
  54.     For X=0 To Max-1
  55.     Next X
  56.   Next Y
  57.   '
  58.   For X=0 To Max-1
  59.     Total=0
  60.     For Y=0 To Sizeb-1
  61.       Total=L2(X,Y)+Total
  62.     Next Y
  63.     L2(X,0)=Total
  64.   Next X
  65.   '
  66.   For X=Max-1 To 0 Step -1
  67.     N=L2(X,0)
  68.     If N>=10
  69.       N=N/10
  70.       Carry=Int(N)
  71.       Answer=(N-Int(N))*10
  72.       L2(X,0)=Int(Answer+0.1)
  73.       L2(X-1,0)=L2(X-1,0)+Carry
  74.     Endif
  75.   Next X
  76.   '
  77.   A$=""
  78.   For X=0 To Max-1
  79.     If L2(X,0)=0 And X=0
  80.     Else
  81.       A$=A$+Str$(L2(X,0))
  82.     Endif
  83.   Next X
  84.   Print A$
  85. Loop
  86. 888888888888888888888888888888888888888888888888888888888888888888888888